package com.egame.manage.biz.web.controller.pu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import cn.egame.common.servlet.WebUtils;
import cn.egame.common.util.Utils;
import cn.egame.interfaces.EnumType.GameStatus;
import cn.egame.interfaces.EnumType.GameTagType;
import cn.egame.interfaces.EnumType.NetworkType;
import cn.egame.interfaces.gc.GameInfo;
import cn.egame.interfaces.gc.GameTagLinkInfo;
import cn.egame.interfaces.pu.AppParameter;

import com.egame.manage.biz.server.ManageClient;
import com.egame.manage.biz.server.gc.GameServiceImpl;
import com.egame.manage.biz.server.gc.GameTagServiceImpl;
import com.egame.manage.biz.utils.ConstVar;
import com.egame.manage.biz.web.controller.BaseController;
import com.lenovo.manager.business.domain.UserBean;

@Controller
@RequestMapping("/store/home")
public class StoreParameterController extends BaseController {

	public StoreParameterController(){		
	}
	public StoreParameterController(HttpServletRequest req,
			HttpServletResponse resp) {
		super(req, resp);
	}
//	
//	@RequestMapping(value = "/recommend/list", method = {RequestMethod.GET,RequestMethod.POST})	
//	public ModelAndView listRecommendPosition(HttpServletRequest req, HttpServletResponse resp) throws Exception{
//		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
//			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
//			loginUserId = userBean.getOperatorId();
//		}
//		//int parentId = WebUtils.getInt(req,"parentId",0);
//		//position可定好
//		int position = WebUtils.getInt(req,"position",0);
//		//游戏名称
//		String gameName = WebUtils.getString(req, "gname","");
//		String recommendname = WebUtils.getString(req, "recommendname","");
//		//这个不需要
//		int tagid = ManageClient.getInstance().getGameTagIdByAppParameterId(appId, loginUserId, position);	
//		ModelAndView mv = new ModelAndView("/new/op/store/homeRecommendList");
//		mv.addObject("position", position);
//		mv.addObject("gameName", gameName);
//		mv.addObject("recommendName", recommendname);
//		//没打标签的游戏
//		List<Integer> gids = GameTagServiceImpl.getInstance().listGidByNotTagId(tagid,0,gameName);
//		//筛选商用状态
//		gids = GameServiceImpl.getInstance().listGameIdsByGameStatus(gids, GameStatus.business);
//		//没打标签游戏列表
//		List<GameInfo> gameList = GameServiceImpl.getInstance().listGameInfoByIds(appId, loginUserId, gids);		
//		//根据TagId，获取推荐游戏列表
//		List<GameInfo> recommendGameList = GameTagServiceImpl.getInstance().listGameInfoByTagId(appId, loginUserId, tagid,recommendname);	
//		mv.addObject("recommendGameList",recommendGameList);
//		
//		//游戏列表删选无标签的列表
//		for(int i=0;i<gameList.size();i++){
//			for(int j=0;j<recommendGameList.size();j++){
//				if(i<gameList.size() && gameList.get(i).getGId() ==recommendGameList.get(j).getGId()){
//					gameList.remove(i);
//				}
//			}
//		}
//		//游戏列表删除gameName为空的列表
//		if(!Utils.stringIsNullOrEmpty(gameName)){
//			for(int i=0;i<gameList.size();i++){
//				if(gameName.equals(gameList.get(i).getGameName())){
//					gameList.remove(i);
//				}
//			}
//		}	
//		
//		mv.addObject("gameList", gameList);
//		//HOT,NEW相关，等接口端定义
//		String tagName = cn.egame.interfaces.ConstVar.HOT_LABEL;
//		int tagId = ManageClient.getInstance().getGameTagIdByGameTagName(appId, loginUserId, GameTagType.in_tag, tagName);
//		
//		Map<Integer, GameTagLinkInfo> map = new HashMap<Integer, GameTagLinkInfo>();
//		GameTagLinkInfo linkBean = null;
//		for(GameInfo bean:recommendGameList){
//			linkBean = ManageClient.getInstance().getGameTagLinkInfoByGId(appId, loginUserId, bean.getGId(), tagId);
//			if(linkBean != null){
//				map.put(bean.getGId(), linkBean);
//			}
//		}
//		mv.addObject("map",map);
//		//推荐位置select，暂不要
////		List<Integer> ids = new ArrayList<Integer>();
////		if(parentId<=0){
////			ids = ManageClient.getInstance().listAppParameterIdsByParentId(appId, loginUserId, 1);
////			ids.addAll(ManageClient.getInstance().listAppParameterIdsByParentId(appId, loginUserId, ConstVar.RECOMMEND_TYPE));
////		}		
////		
////		List<AppParameter> list = ManageClient.getInstance().listAppParameterByIds(position, tagid, ids);
////		mv.addObject("positionList", list);
//		
//		return mv;		
//	}
}
